#ifndef DB_CPP
#define DB_CPP

#include "DB.h"

char DBFILE[6] = "db.db";

string vecStrToStr(vector<string>& vec)
{
	string toRtn = "";
	for(vector<string>::iterator i = vec.begin(); i < vec.end(); i++)
	{
		if(i < vec.end()-1)
			toRtn += *i + ",";
		else
			toRtn += *i;
	}
	return toRtn;
}

vector<string> strToVecStr(string& str)
{
	vector<string> toRtn;
	string::size_type pos = 0;
	
	do{
		if(pos == 0)
			toRtn.push_back(str.substr(pos, 7));
		else
			toRtn.push_back(str.substr(pos+1, 7));
		pos = str.find_first_of(',', pos+1);
	}while(pos != string::npos);
	str.clear();
	return toRtn;
}

string maStmt(char op, vector<MemberAccount*>& vec)
{
	string stmtHead, stmtFull, table;
	stringstream stmtBody;
	string enableFK = "PRAGMA foreign_keys = ON ";

	switch(op)
	{
		case 'i': 
		{
			stmtHead = "INSERT INTO MEMBERACCOUNT VALUES";
			vector<string> rGFVec;
			vector<string> rRFVec;			
			for(vector<MemberAccount*>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				rGFVec = (*i)->getReviewGrantedFor();
				rRFVec = (*i)->getReviewRequestedFor();
				
				stmtBody << "(\'" 
						<< (*i)->getMemberID() << "\',\'" 
						<< (*i)->getMemberName() << "\',\'"
						<< charStrToIntStr(encrypt((*i)->getMemberPassword())) << "\',\'";
				if(!rGFVec.empty())
					stmtBody << vecStrToStr(rGFVec);
				stmtBody << "\',\'";
				if(!rRFVec.empty())
					stmtBody << vecStrToStr(rRFVec);
				stmtBody << "\'," << (*i)->getRewardPoints() 
						<< ",\'" <<  (*i)->getType()
						<< "\');\n";
				
				stmtFull += stmtHead + stmtBody.str();
				stmtBody.str(string());
			}
		}
			break;
		case 's': 
			stmtFull = "SELECT * FROM MEMBERACCOUNT ORDER BY MemberID ASC;";
			break;
		case 'u':
		{
			stmtHead = "UPDATE MEMBERACCOUNT SET ";
			vector<string> rGFVec;
			vector<string> rRFVec;
			for(vector<MemberAccount*>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				rGFVec = (*i)->getReviewGrantedFor();
				rRFVec = (*i)->getReviewRequestedFor();
				stmtBody << "MEMBERNAME = \'" << (*i)->getMemberName() 
						<< "\', MEMBERPASSWORD = \'" << charStrToIntStr(encrypt((*i)->getMemberPassword()))
						<< "\', REVIEWGRANTEDFOR = \'";
				if(!rGFVec.empty())
					stmtBody << vecStrToStr(rGFVec);
				stmtBody << "\', REVIEWREQUESTEDFOR = \'";
				if(!rRFVec.empty())
					stmtBody << vecStrToStr(rRFVec);
				stmtBody << "\', REWARDSPOINTS = " << (*i)->getRewardPoints()
						<< ", TYPE = \'"+ (*i)->getType() 
						<< "\' WHERE MEMBERID = \'" << (*i)->getMemberID()
						<< "\';\n";
				stmtFull += stmtHead + stmtBody.str();
				stmtBody.str(string());
			}
			stmtFull += enableFK;			
		}
			break;
		case 'd':
			stmtHead = "DELETE FROM MEMBERACCOUNT WHERE ";
			for(vector<MemberAccount*>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				stmtBody << "MEMBERID = \'" << (*i)->getMemberID()
						<< "\';\n";
				stmtFull += stmtHead + stmtBody.str();
				stmtBody.str(string());
			}
			stmtFull += enableFK;			
			break;
	}
	return stmtFull;
}

string hiStmt(char op, vector<HotelItem>& vec)
{
	string stmtHead, stmtFull;
	stringstream stmtBody;
	string enableFK = "PRAGMA foreign_keys = ON ";
	
	switch(op)
	{
		case 'i': 
			stmtHead = "INSERT INTO HotelItem VALUES";
			for(vector<HotelItem>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				stmtBody << "(\'" 
						<< i->getHotelID() << "\',\'" 
						<< i->getName() << "\',\'"
						<< i->getAddress() << "\',\'"
						<< i->getCountry() << "\',\'"
						<< i->getDistrict() << "\',\'"
						<< i->getCategory() << "\');\n";						
					stmtFull += stmtHead + stmtBody.str();
					stmtBody.str(string());
				}
			break;
		case 's': 
			stmtFull = "SELECT * FROM HotelItem ORDER BY HotelID ASC;";
			break;
		case 'u': 
			stmtHead = "UPDATE HotelItem SET ";
			for(vector<HotelItem>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				stmtBody << "NAME = \'" << i->getName()
						<< "\', ADDRESS = \'" << i->getAddress()
						<< "\', COUNTRY = \'" << i->getCountry()
						<< "\', DISTRICT = \'" << i->getDistrict()
						<< "\', CATEGORY = \'" << i->getCategory() 
						<< "\' WHERE HOTELID = \'" << i->getHotelID()
						<< "\';\n";
					stmtFull += stmtHead + stmtBody.str();
					stmtBody.str(string());
				}
			stmtFull += enableFK;			
			break;
		case 'd': 
			stmtHead = "DELETE FROM HotelItem WHERE ";
			for(vector<HotelItem>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				stmtBody << "HOTELID = '" 
						<< i->getHotelID() << "\'\n;";					
					stmtFull += stmtHead + stmtBody.str();
					stmtBody.str(string());
				}
			stmtFull += enableFK;			
			break;			
	}
	return stmtFull;
}

string hrStmt(char op, vector<HotelReview>& vec)
{
	string stmtHead, stmtFull;
	stringstream stmtBody;
	string enableFK = "PRAGMA foreign_keys = ON ";
	
	switch(op)
	{
		case 'i': 
			stmtHead = "INSERT INTO HotelReview VALUES";
			for(vector<HotelReview>::iterator i = vec.begin(); i < vec.end(); i++)
			{
					stmtBody << "(\'" 
							<< i->getReviewId() << "\',\'" 
							<< i->getHotelId() << "\',\'"
							<< i->getCustomerId() << "\'," 
							<< i->getLocationRating() << ","
							<< i->getValueForMoneyRating() << "," 
							<< i->getComfortRating() << ","
							<< i->getServiceRating() << ","
							<< i->getAverageRating() << ",\'"
							<< i->getComments() << "\');\n";			
					stmtFull += stmtHead + stmtBody.str();
					stmtBody.str(string());
				}
			break;
		case 's': 
			stmtFull = "SELECT * FROM HotelReview ORDER BY ReviewID ASC;";
			break;
		case 'u': 
			stmtHead = "UPDATE HotelReview SET ";
			for(vector<HotelReview>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				stmtBody << "HOTELID = \'" << i->getHotelId()
						<< "\', ACCOUNTID = \'" << i->getCustomerId()
						<< "\', LOCATIONRATING = " << i->getLocationRating()
						<< ", VFMRATING = " << i->getValueForMoneyRating()
						<< ", COMFORTRATING = " << i->getComfortRating()
						<< ", SERVICERATING = " << i->getServiceRating()
						<< ", AVERAGERATING = " << i->getAverageRating()
						<< ", COMMENTS = \'" << i->getComments()
						<< "\' WHERE REVIEWID = \'" << i->getReviewId()
						<< "\';\n";
					stmtFull += stmtHead + stmtBody.str();
					stmtBody.str(string());
				}
			stmtFull += enableFK;			
			break;
		case 'd': 
			stmtHead = "DELETE FROM HotelReview WHERE ";
			for(vector<HotelReview>::iterator i = vec.begin(); i < vec.end(); i++)
			{
				stmtBody << "REVIEWID = \'" << i->getReviewId()
						<< "\';\n";
					stmtFull += stmtHead + stmtBody.str();
					stmtBody.str(string());
			}
			stmtFull += enableFK;			
			break;
	}
	return stmtFull;
}

int dbMemberAccount(char op, vector<MemberAccount*>& vec)
{
	sqlite3* pDb = NULL;
	sqlite3_stmt* ppStmt = NULL;
	string stmt;
	int ret = 1;
	do{
		// open connection to a DB
		if (SQLITE_OK != (ret = sqlite3_open(DBFILE, &pDb)))
		{
				cout << "Failed to open connection: " << ret << "\n";
				break;
		}
		
		stmt = maStmt(op, vec);
		//cout << stmt << endl;
		
		if(op == 's')
		{
			// prepare the statement
			if (SQLITE_OK != (ret = sqlite3_prepare_v2(pDb, stmt.c_str(), -1, &ppStmt, NULL)))
			{
					cout << "Failed to prepare: " << ret << " " << sqlite3_errmsg(pDb) << "\n";
					break;
			}
			// step to 1st row of data
			if (SQLITE_ROW != (ret = sqlite3_step(ppStmt))) // see documentation, this can return more values as success
			{
				cout << "Failed to step: " << ret << " " << sqlite3_errmsg(pDb);
				break;
			}

			string revGrantedFor;
			string revRequestedFor;
			char *type;
			MemberAccount* pMA;
			AdminAccount* pAA;
			do{
				type = (char*)sqlite3_column_text(ppStmt, 6);
				
				string pwdEN = (char*)sqlite3_column_text(ppStmt, 2);
				string pwdDE = decrypt(intStrToCharStr(pwdEN));
				
				if(strcmp(type,"Member") == 0)
				{			
					pMA = new MemberAccount;
					
					pMA->setMemberID((char*)sqlite3_column_text(ppStmt, 0));
					pMA->setMemberName((char*)sqlite3_column_text(ppStmt, 1));
					pMA->setMemberPassword(pwdDE);
					revGrantedFor = (char*)sqlite3_column_text(ppStmt, 3);
					if(!revGrantedFor.empty())
						pMA->setReviewGrantedFor(strToVecStr(revGrantedFor));
					revRequestedFor = (char*)sqlite3_column_text(ppStmt, 4);
					if(!revRequestedFor.empty())
						pMA->setReviewRequestedFor(strToVecStr(revRequestedFor));
					pMA->setRewardPoints(sqlite3_column_int(ppStmt, 5));
					pMA->setAuthenticate(false);
					pMA->setType((char*)sqlite3_column_text(ppStmt, 6));

					vec.push_back(pMA);
				}
				else
				{
					pAA = new AdminAccount;
					
					pAA->setMemberID((char*)sqlite3_column_text(ppStmt, 0));
					pAA->setMemberName((char*)sqlite3_column_text(ppStmt, 1));
					pAA->setMemberPassword(pwdDE);
					revGrantedFor = (char*)sqlite3_column_text(ppStmt, 3);
					if(!revGrantedFor.empty())
						pAA->setReviewGrantedFor(strToVecStr(revGrantedFor));
					revRequestedFor = (char*)sqlite3_column_text(ppStmt, 4);
					if(!revRequestedFor.empty())
						pAA->setReviewGrantedFor(strToVecStr(revRequestedFor));		
					pAA->setRewardPoints(sqlite3_column_int(ppStmt, 5));
					pAA->setAuthenticate(false);
					pAA->setType((char*)sqlite3_column_text(ppStmt, 6));

					vec.push_back(pAA);
				}
				ret = sqlite3_step(ppStmt);
			}while(ret == SQLITE_ROW);
			// cleanup
			if (NULL != ppStmt)
				sqlite3_finalize(ppStmt);
		}
		else
		{
			char* errmsg;
			if (SQLITE_ABORT == (ret = sqlite3_exec(pDb, stmt.c_str(), NULL, NULL, &errmsg)))
			{
				cout << "Failed to execute: " << sqlite3_errstr(ret) << " " << errmsg;
				sqlite3_free(errmsg);
				break;
			}
		}
		if (NULL != pDb)
			sqlite3_close(pDb);		
		ret = 0;
	} while (false);
	return ret;
}

int dbHotelItem(char op, vector<HotelItem>& vec)
{
	sqlite3* pDb = NULL;
	sqlite3_stmt* ppStmt = NULL;
	string stmt;
	int ret = 1;
	do{
		// open connection to a DB
		if (SQLITE_OK != (ret = sqlite3_open(DBFILE, &pDb)))
		{
				cout << "Failed to open connection: " << ret << "\n";
				break;
		}
		
		stmt = hiStmt(op, vec);
		//cout << stmt << endl;
		
		if(op == 's')
		{
			// prepare the statement
			if (SQLITE_OK != (ret = sqlite3_prepare_v2(pDb, stmt.c_str(), -1, &ppStmt, NULL)))
			{
					cout << "Failed to prepare: " << ret << " " << sqlite3_errmsg(pDb) << "\n";
					break;
			}
			// step to 1st row of data
			if (SQLITE_ROW != (ret = sqlite3_step(ppStmt))) // see documentation, this can return more values as success
			{
				cout << "Failed to step: " << ret << " " << sqlite3_errmsg(pDb);
				break;
			}
			HotelItem hotelItem;
			do{
				hotelItem.setHotelID((char*)sqlite3_column_text(ppStmt, 0));
				hotelItem.setName((char*)sqlite3_column_text(ppStmt, 1));
				hotelItem.setAddress((char*)sqlite3_column_text(ppStmt, 2));
				hotelItem.setCountry((char*)sqlite3_column_text(ppStmt, 3));
				hotelItem.setDistrict((char*)sqlite3_column_text(ppStmt, 4));
	//						hotelItem.setTelNo(sqlite3_column_text(ppStmt, 5));
	//						hotelItem.setFaxNo(sqlite3_column_text(ppStmt, 6));
	//						hotelItem.setEmail(sqlite3_column_text(ppStmt, 7));
	//						hotelItem.setWebsite(sqlite3_column_text(ppStmt, 8));
				hotelItem.setCategory((char*)sqlite3_column_text(ppStmt, 5));
				/*
			cout << "(\'" 
						<< hotelItem.getHotelID() << "\',\'" 
						<< hotelItem.getName() << "\',\'"
						<< hotelItem.getAddress() << "\',\'"
						<< hotelItem.getCountry() << "\',\'"
						<< hotelItem.getDistrict() << "\',\'"
						<< hotelItem.getCategory() << "\')\n";
				 */
				vec.push_back(hotelItem);
				ret = sqlite3_step(ppStmt);
			}while(ret == SQLITE_ROW);
			// cleanup
			if (NULL != ppStmt)
				sqlite3_finalize(ppStmt);
		}
		else
		{
			char* errmsg;
			if (SQLITE_ABORT == (ret = sqlite3_exec(pDb, stmt.c_str(), NULL, NULL, &errmsg)))
			{
				cout << "Failed to execute: " << sqlite3_errstr(ret) << " " << errmsg;
				sqlite3_free(errmsg);
				break;
			}
		}
		if (NULL != pDb)
			sqlite3_close(pDb);		
		ret = 0;
	} while (false);
	return ret;
}

int dbHotelReview(char op, vector<HotelReview>& vec)
{
	sqlite3* pDb = NULL;
	sqlite3_stmt* ppStmt = NULL;
	string stmt;
	int ret = 1;
	do{
		// open connection to a DB
		if (SQLITE_OK != (ret = sqlite3_open(DBFILE, &pDb)))
		{
				cout << "Failed to open connection: " << ret << "\n";
				break;
		}
		
		stmt = hrStmt(op, vec);
		//cout << stmt << endl;
		
		if(op == 's')
		{
			// prepare the statement
			if (SQLITE_OK != (ret = sqlite3_prepare_v2(pDb, stmt.c_str(), -1, &ppStmt, NULL)))
			{
					cout << "Failed to prepare: " << ret << " " << sqlite3_errmsg(pDb) << "\n";
					break;
			}
			// step to 1st row of data
			if (SQLITE_ROW != (ret = sqlite3_step(ppStmt))) // see documentation, this can return more values as success
			{
				cout << "Failed to step: " << ret << " " << sqlite3_errmsg(pDb);
				break;
			}
			
			HotelReview hotelReview;
			do{
				hotelReview.setReviewId((char*)sqlite3_column_text(ppStmt, 0));
				hotelReview.setHotelId((char*)sqlite3_column_text(ppStmt, 1));
				hotelReview.setCustomerId((char*)sqlite3_column_text(ppStmt, 2));
				hotelReview.setLocationRating(sqlite3_column_int(ppStmt, 3));
				hotelReview.setValueForMoneyRating(sqlite3_column_int(ppStmt, 4));
				hotelReview.setComfortRating(sqlite3_column_int(ppStmt, 5));
				hotelReview.setServiceRating(sqlite3_column_int(ppStmt, 6));
				hotelReview.setAverageRating(sqlite3_column_double(ppStmt, 7));
				hotelReview.setComments((char*)sqlite3_column_text(ppStmt, 8));
				
				vec.push_back(hotelReview);
				ret = sqlite3_step(ppStmt);
			}while(ret == SQLITE_ROW);

			// cleanup
			if (NULL != ppStmt)
				sqlite3_finalize(ppStmt);
		}
		else
		{
			char* errmsg;
			if (SQLITE_ABORT == (ret = sqlite3_exec(pDb, stmt.c_str(), NULL, NULL, &errmsg)))
			{
				cout << "Failed to execute: " << sqlite3_errstr(ret) << " " << errmsg;
				sqlite3_free(errmsg);
				break;
			}
		}
		if (NULL != pDb)
			sqlite3_close(pDb);		
		ret = 0;
	} while (false);
	return ret;
}

int dbGetAvgHotelRating(string HI, float& avgRating)
{
	sqlite3* pDb = NULL;
	sqlite3_stmt* ppStmt = NULL;
	string stmt;
	int ret = 1;
	do{
		// open connection to a DB
		if (SQLITE_OK != (ret = sqlite3_open(DBFILE, &pDb)))
		{
				cout << "Failed to open connection: " << ret << "\n";
				break;
		}
		
		stmt = "SELECT AVG(AVERAGERATING) FROM HotelReview WHERE HotelID = \'" + HI + "\';";
		//cout << stmt << endl;
		
		// prepare the statement
		if (SQLITE_OK != (ret = sqlite3_prepare_v2(pDb, stmt.c_str(), -1, &ppStmt, NULL)))
		{
				cout << "Failed to prepare: " << ret << " " << sqlite3_errmsg(pDb) << "\n";
				break;
		}
		// step to 1st row of data
		if (SQLITE_ROW != (ret = sqlite3_step(ppStmt))) // see documentation, this can return more values as success
		{
			cout << "Failed to step: " << ret << " " << sqlite3_errmsg(pDb);
			break;
		}

		avgRating = (float)sqlite3_column_double(ppStmt, 0);
		
		// cleanup
		if (NULL != ppStmt)
			sqlite3_finalize(ppStmt);

		if (NULL != pDb)
			sqlite3_close(pDb);		
		ret = 0;
	} while (false);
	return ret;
}

int dbGetHotelSummary(vector<HotelSummary>& vec)
{
	sqlite3* pDb = NULL;
	sqlite3_stmt* ppStmt = NULL;
	string stmt;
	int ret = 1;
	do{
		// open connection to a DB
		if (SQLITE_OK != (ret = sqlite3_open(DBFILE, &pDb)))
		{
				cout << "Failed to open connection: " << ret << "\n";
				break;
		}
		
		stmt = "SELECT HotelReview.HotelID ASC, name, AVG(locationrating), AVG(vfmrating), AVG(comfortrating), AVG(servicerating), AVG(averagerating) FROM HotelReview LEFT OUTER JOIN HotelItem ON HotelReview.HotelID = HotelItem.HotelID GROUP BY HotelReview.HotelID;";
		//cout << stmt << endl;
		
		// prepare the statement
		if (SQLITE_OK != (ret = sqlite3_prepare_v2(pDb, stmt.c_str(), -1, &ppStmt, NULL)))
		{
				cout << "Failed to prepare: " << ret << " " << sqlite3_errmsg(pDb) << "\n";
				break;
		}
		// step to 1st row of data
		if (SQLITE_ROW != (ret = sqlite3_step(ppStmt))) // see documentation, this can return more values as success
		{
			cout << "Failed to step: " << ret << " " << sqlite3_errmsg(pDb);
			break;
		}

		HotelSummary hotelSummary;
		do{
			hotelSummary.hotelID = (char*)sqlite3_column_text(ppStmt, 0);
			if(hotelSummary.hotelID.empty())
			{
				ret = 1;
				break;
			}
			hotelSummary.name = (char*)sqlite3_column_text(ppStmt, 1);
			hotelSummary.locationRating = sqlite3_column_double(ppStmt, 2);
			hotelSummary.valueForMoneyRating = sqlite3_column_double(ppStmt, 3);
			hotelSummary.comfortRating = sqlite3_column_double(ppStmt, 4);
			hotelSummary.serviceRating = sqlite3_column_double(ppStmt, 5);
			hotelSummary.averageRating = sqlite3_column_double(ppStmt, 6);

			vec.push_back(hotelSummary);
			ret = sqlite3_step(ppStmt);
		}while(ret == SQLITE_ROW);
		if(ret == 1)
			break;
		// cleanup
		if (NULL != ppStmt)
			sqlite3_finalize(ppStmt);

		if (NULL != pDb)
			sqlite3_close(pDb);		
		ret = 0;
	} while (false);
	return ret;
}

int dbUpdateMemberID(string& mID, MemberAccount*& i)
{
	sqlite3* pDb = NULL;
	sqlite3_stmt* ppStmt = NULL;
	stringstream stmt;
	int ret = 1;
	do{
		// open connection to a DB
		if (SQLITE_OK != (ret = sqlite3_open(DBFILE, &pDb)))
		{
				cout << "Failed to open connection: " << ret << "\n";
				break;
		}
		
		vector<string>	rGFVec = i->getReviewGrantedFor();
		vector<string>	rRFVec = i->getReviewRequestedFor();
			
		stmt << "UPDATE MemberAccount SET "
				 << "MEMBERID = \'" << i->getMemberID() << "\', "
				 << "MEMBERNAME = \'" << i->getMemberName() 
				 << "\', MEMBERPASSWORD = \'" << charStrToIntStr(encrypt(i->getMemberPassword()))
				 << "\', REVIEWGRANTEDFOR = \'";
				if(!rGFVec.empty())
					stmt << vecStrToStr(rGFVec);
				stmt << "\', REVIEWREQUESTEDFOR = \'";
				if(!rRFVec.empty())
					stmt << vecStrToStr(rRFVec);
				stmt << "\', REWARDSPOINTS = " << i->getRewardPoints()
						<< ", TYPE = \'"+ i->getType() 
						<< "\' WHERE MEMBERID = \'" << mID
						<< "\';\n";
		cout << stmt.str() << endl;

		char* errmsg;
		if (SQLITE_ABORT == (ret = sqlite3_exec(pDb, stmt.str().c_str(), NULL, NULL, &errmsg)))
		{
			cout << "Failed to execute: " << sqlite3_errstr(ret) << " " << errmsg;
			sqlite3_free(errmsg);
			break;
		}
		
		if (NULL != pDb)
			sqlite3_close(pDb);		
		ret = 0;
	} while (false);
	return ret;	
}


/*	
int main()
{
	vector<HotelSummary> hsVec;
	dbGetHotelSummary(hsVec);
	
	for(vector<HotelSummary>::iterator i = hsVec.begin(); i < hsVec.end(); i++)
	{
		cout << i->hotelID << " "
				<< i->name << " "
				<< i->locationRating << " "
				<< i->valueForMoneyRating << " "
				<< i->comfortRating << " "
				<< i->serviceRating << "\n";
	}
	
	
	MemberAccount *ma = new MemberAccount(string("ID01001"),string("name"),string("password"),99999);
	ma->setType("Member");
	string newMAID("ID00001");
	dbUpdateMemberID(newMAID, ma);

	vector<MemberAccount*> maVec;
	vector<string> rgVec;
	vector<string> rrVec;
	rgVec.push_back(string("HI00001"));
	rgVec.push_back(string("HI00010"));
	rrVec.push_back(string("HI00030"));
	rrVec.push_back(string("HI00003"));
	MemberAccount* maAcc = new MemberAccount(string("ID01001"),string("name"),string("password"),99999);
	MemberAccount* maAcc1 = new MemberAccount(string("ID01002"),string("name"),string("password"),99999);
	maAcc->setReviewGrantedFor(rgVec);
	maAcc->setReviewRequestedFor(rrVec);
	maAcc->setType(string("Member"));
	maAcc1->setType(string("Admin"));
	maVec.push_back(maAcc);
	maVec.push_back(maAcc1);


	int rtn = dbMemberAccount('i', maVec);
	if(rtn == 0)
	{
		cout << maVec.size() << endl;
		for(vector<MemberAccount*>::iterator i = maVec.begin(); i < maVec.end(); i++)
		{
				vector<string> rGFVec = (*i)->getReviewGrantedFor();
				vector<string> rRFVec = (*i)->getReviewRequestedFor();
						
			cout << "(" << (*i)->getMemberID() << ", " 
											<< (*i)->getMemberName() << ", "
											<< (*i)->getMemberPassword() << ", ";
				if(!rGFVec.empty())
					cout << vecStrToStr(rGFVec);
			cout << ", ";
				if(!rRFVec.empty())
					cout << vecStrToStr(rRFVec);
			cout << ", "	<< (*i)->getRewardPoints() << ", "
											<< (*i)->getType() << ")\n";
		}
	}*/
/*

	vector<HotelItem> hiVec;
	HotelItem hi(string("HI00001"), string("name"), string("affress"), string("country"), string("district"),string("category"));
	HotelItem hi1(string("HI00002"), string("name"), string("affress"), string("country"), string("district"),string("category"));	
	hiVec.push_back(hi);
	hiVec.push_back(hi1);
	int rtn = dbHotelItem('d', hiVec);
	
	
	if(rtn == 0)
	{
		cout << hiVec.size() << endl;
		for(vector<HotelItem>::iterator i = hiVec.begin(); i < hiVec.end(); i++)
		{
			cout << "(\'" 
						<< i->getHotelID() << "\',\'" 
						<< i->getName() << "\',\'"
						<< i->getAddress() << "\',\'"
						<< i->getCountry() << "\',\'"
						<< i->getDistrict() << "\',\'"
						<< i->getCategory() << "\')\n";
		}
	}
	
	vector<HotelReview> hrVec;
	HotelReview hr(string("HR03911"),string("HI00100"),string("ID00001"),2,2,2,2);
	HotelReview hr1(string("HR03912"),string("HI00001"),string("ID00002"),2,2,2,2);
	hrVec.push_back(hr);
	hrVec.push_back(hr1);

	int rtn = dbHotelReview('s', hrVec);
	
	if(rtn == 0)
	{
		cout << hrVec.size() << endl;
		for(vector<HotelReview>::iterator i = hrVec.begin(); i < hrVec.end(); i++)
		{
			cout << "(\'" 
							<< i->getReviewId() << "\',\'" 
							<< i->getHotelId() << "\',\'"
							<< i->getCustomerId() << "\'," 
							<< i->getLocationRating() << ","
							<< i->getValueForMoneyRating() << "," 
							<< i->getComfortRating() << ","
							<< i->getServiceRating() << ");\n";
		}
	}
}
*/	
#endif